hotplug scripts: better same_vm checks
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 19 Aug 2009 12:11:33 +0000 (13:11 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 19 Aug 2009 12:11:33 +0000 (13:11 +0100)
currently the function same_vm in block-common.sh is the one
responsible for detecting if two block devices can be used at the same
time by two VMs. This can be allowed in few specific cases: when the
two VMs are actually the same VM and when the two VMs are the guest
and its stubdomain. We need to expand these exceptions to handle
properly save restore issues: this patch adds to the exceptions the
case when two VMs are the same VM because of save\restore races, and
when two VMs are the guest and the stubdomain of the previous guest,
again during save\restore.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/hotplug/Linux/block-common.sh

index efedbf50d4246767c86fcbaf87ddd9e3270eef08..cc374efeb45389d8b7176000c47b4c17cabbb515 100644 (file)
@@ -112,6 +112,14 @@ same_vm()
                   "$FRONTEND_UUID")
   local target=$(xenstore_read_default  "/local/domain/$FRONTEND_ID/target"   \
                  "-1")
-  [ "$FRONTEND_UUID" = "$othervm" -o "$target" = "$otherdom" ]
+  local otarget=$(xenstore_read_default  "/local/domain/$otherdom/target"   \
+                 "-1")
+  local otvm=$(xenstore_read_default  "/local/domain/$otarget/vm"   \
+                 "-1")
+  otvm=${otvm%-1}
+  othervm=${othervm%-1}
+  local frontend_uuid=${FRONTEND_UUID%-1}
+  
+  [ "$frontend_uuid" = "$othervm" -o "$target" = "$otherdom" -o "$frontend_uuid" = "$otvm" ]
 }